package org.advanced.io;

import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.Socket;

/**
 * @author John.zhang
 * @version Id: InitialIo, v 1.0 2020/12/14 11:16 ZhiYong Exp $
 * 几种IO介绍
 */
public class InitialIo {

    public static void main(String[] args) throws Exception {
        //磁盘IO
        FileInputStream fileInputStream = new FileInputStream("C:/data/io/io.txt");
        //内存IO
        String str = "Hello World";
        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(str.getBytes());
        int i = 0;
        while ((i = byteArrayInputStream.read()) != -1) {
            System.out.print((char) i);
        }
        //键盘IO
        InputStream inputStream = System.in;
        int j = 0;
        while ((j = inputStream.read()) != -1) {
            System.out.print((char) j);
        }
        //网络IO
        Socket socket = new Socket();
        socket.getInputStream();
        socket.getOutputStream();
    }

}
